#ifndef _OPENGL_TEXTURE_H
#define _OPENGL_TEXTURE_H

#include "engine.h"

namespace engine
{

    // class OpenGLFramebuffer;

    class Texture2D
    {
    public:
        // friend class OpenGLFramebuffer;

        virtual ~Texture2D() = default;

        void bind()
        {
            glBindTexture(GL_TEXTURE_2D, this->texture);
        }
        void generate(unsigned int width, unsigned int height, unsigned char *data);

        uint32_t getWidth() { return width; }
        uint32_t getHeight() { return height; }

    protected:
        GLuint texture = 0;
        unsigned int width, height;
        unsigned int Wrap_S;     // wrapping mode on S axis
        unsigned int Wrap_T;     // wrapping mode on T axis
        unsigned int Filter_Min; // filtering mode if texture pixels < screen pixels
        unsigned int Filter_Max; // filtering mode if texture pixels > screen pixels
    };

    class ColorTexture2D : public Texture2D
    {
    public:
        ColorTexture2D(const char *path);
        // OpenGLColorTexture2D(uint32_t w, uint32_t h);
        ~ColorTexture2D();

        // void setData(const void *data) override;

        void bind()
        {
            glBindTexture(GL_TEXTURE_2D, this->texture);
        }

    private:
        GLenum internal_format_ = GL_RGBA;
        GLenum data_format_ = GL_RGBA;
    };

    // class OpenGLDepthTexture2D : public OpenGLTexture2D
    // {
    // public:
    //     OpenGLDepthTexture2D(uint32_t w, uint32_t h);
    //     ~OpenGLDepthTexture2D();

    //     void SetData(const void *data) override;
    // };

    // class OpenGLDepthStencilTexture2D : public OpenGLTexture2D
    // {
    // public:
    //     OpenGLDepthStencilTexture2D(uint32_t w, uint32_t h);
    //     ~OpenGLDepthStencilTexture2D();

    //     void SetData(const void *data) override;
    // };

}

#endif
